package StatePattern.example2;

public class RunningState extends ThreadState {
    private static ThreadState singleton = new RunningState();

    RunningState() {

    }

    public static ThreadState getInstance() {
        return singleton;
    }

    @Override
    public String getStateName() {
        return "运行态";
    }

    @Override
    public void start(ThreadContext threadContext) {
        System.out.println("Error");
    }

    @Override
    public void suspend(ThreadContext threadContext) {
        threadContext.setThreadState(BlockedState.getInstance());
    }

    @Override
    public void resume(ThreadContext threadContext) {
        threadContext.setThreadState(RunningState.getInstance());
    }

    @Override
    public void stop(ThreadContext threadContext) {
        threadContext.setThreadState(DeadState.getInstance());
    }

    @Override
    public void getCpu(ThreadContext threadContext) {
        System.out.println("Error");
    }
}
